let https = require('https')
module.exports = (req, res) => {
	let options = {
		host: 'aip.baidubce.com',
		path: '/rest/2.0/face/v3/search?access_token="' + access_token + '"',
		method: 'POST',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded',
		}
	}
	let contents = JSON.stringify({
		image: req.body.img.replace(/\s/g, "+").replace(/^data:image\/\w+\Wbase64,/, ""),
		image_type: "BASE64",
		group_id_list: "test"
	})

	let req_baidu = https.request(options, function(res_baidu) {
		res_baidu.setEncoding('utf8')
		res_baidu.on('data', function(chunk) {
			res.send(chunk)
			req.app.locals.username = JSON.parse(chunk).result.user_list[0].user_id
		})
	})
	req_baidu.write(contents)
	req_baidu.end()
}
